﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;
using Com.CMS263.DAO;

namespace Com.CMS263.BLL
{
    public class DealInfoBLL:BaseBLL<DealInfo>
    {
        DealInfoDAO dao = new DealInfoDAO();
        public DealInfo entity = new DealInfo();
       
        public override DealInfo GetModel()
        {
            return entity;
        }
        /// <summary>
        /// 根据团购单号查询所有交易订单 1成功的0未成功的 -1全部
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="page"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public IList<DealInfo> GetDealInfoByGroup(int state,int groupId, int page, int pagesize)
        {
            return dao.GetDealInfoByGroup(state ,groupId, page, pagesize);
        }
        public IList<DealInfo> GetDealInfoByGroup(int groupId)
        {
            return dao.GetDealInfoByGroup(groupId);
        }
        /// <summary>
        /// 根据团购单号查询交易次数
        /// </summary>
        /// <param name="groupId"></param>
        /// <returns></returns>
        public int GetCountDealInfoByGroup(int state,int groupId)
        {
            return dao.GetCountDealInfoByGroup(state,groupId);
        }
        /// <summary>
        /// 根据用户ID来显示个订单
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="pagesize"></param>
        /// <param name="pageindex"></param>
        /// <returns></returns>
        public IList<DealInfo> GetAllOrderByUserId(int userid,string key,int pagesize,int pageindex)
        {
            return dao.GetAllOrderByUserId(userid,key,pagesize,pageindex);
        }
        public int GetAllOrderCountById(int userid,string key)
        { return dao.GetAllOrderCountById(userid,key); }
        /// <summary>
        /// 根据ID来删除订单
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public bool Delete(int orderid)
        {
            return dao.Delete(orderid);
        }
        public DealInfo GetDealInfoById(int id)
        {
            return dao.GetDealInfoById(id);
        }
        public IList<DealInfo> GetSearch(string str, int pagesize, int pageindex)
        {
            return dao.GetSearch(str, pagesize, pageindex);
        }
        public int GetSearchByName(string str)
        {
            return dao.GetSearchByName(str);
        }

         #region 个人中心订单查询
        /// <summary>
        /// 订单查询ByState
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="state"></param>
        /// <param name="pagesize"></param>
        /// <param name="pageindex"></param>
        /// <returns></returns>
        public IList<DealInfo> GetAllOrderByUserId(int userid, int state, int pagesize, int pageindex)
        {
            return dao.GetAllOrderByUserId(userid, state, pagesize, pageindex);
        }
        /// <summary>
        /// 订单查询ByState
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public int GetAllOrderCountById(int userid, int state)
        {
            return dao.GetAllOrderCountById(userid, state);
        }
         #endregion

        #region 根据订单号查询单个实体
        /// <summary>
        /// 根据订单号查询单个实体
        /// </summary>
        /// <param name="orderid">订单号</param>
        /// <returns></returns>
        public DealInfo GetDealInfoByOrderId(string orderid)
        {
            return dao.GetDealInfoByOrderId(orderid);
        }
        #endregion

        /// <summary>
        /// 查询各种状态下，订单的数量
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public int GetCountByState(int id,int p)
        {
            return dao.GetCountByState(id,p);
        }
        
        #region 查询订单列表可根据条件查询
        /// <summary>
        /// 查询订单列表可根据条件查询
        /// </summary>
        /// <param name="Condition">查询条件最少要加排序条件</param>
        /// <param name="page"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public IList<DealInfo> GetDealInfo(string Condition, int page, int pagesize)
        {
            return dao.GetDealInfo(Condition, page, pagesize);
        }
        #endregion

        #region 查询订单列表条数可根据条件查询
        /// <summary>
        /// 查询订单列表条数可根据条件查询
        /// </summary>
        /// <returns></returns>
        public int GetDealInfo()
        {
            return dao.GetDealInfo();
        }
        #endregion

         #region 批量修改状态
        /// <summary>
        /// 批量修改状态
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public int UpdateState(string ids, int state)
        {
            return dao.UpdateState(ids, state);
        }
        #endregion

         #region 根据Id(修改state)
        /// <summary>
        /// 根据Id(修改state)
        /// </summary>
        /// <param name="id"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public bool UpdateStateById(int id, int state)
        {
            return dao.UpdateStateById(id, state);
        }
        #endregion

        #region 模糊查询list
        /// <summary>
        /// 模糊查询list
        /// </summary>
        /// <param name="key"></param>
        /// <param name="page"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public IList<DealInfo> GetLike(string key, int page, int pagesize)
        {
            return dao.GetLike(key, page, pagesize);
        }
        #endregion

        #region 模糊查询总数
        /// <summary>
        /// 模糊查询总数
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public int GetLike(string key)
        {
            return dao.GetLike(key);
        }
        #endregion

        #region 取得State
        /// <summary>
        /// 取得State
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public int GetStateByLike(string key)
        {
            return dao.GetStateByLike(key);
        }
        #endregion
    }
}
